package com.example.demo.service.impl;

import com.example.demo.entity.User;
import com.example.demo.mapper.UserMapper;
import com.example.demo.service.UserService;
import com.example.demo.utils.ResultVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class UserServiceImpl implements UserService {
    @Autowired
    private UserMapper userMapper;
    @Override
    public ResultVO login(String username, String password) {
       User user= userMapper.login(username);
       if(user==null){
           return new ResultVO(1000,"用户名不存在",null);
       }else{
           if(user.getPassword().equals(password)){
               return new ResultVO(1001,"登录成功",user);
           }else{
               return new ResultVO(1002,"密码错误",null);
           }
       }
    }
    @Override
    public int register(User user){
        return userMapper.register(user);
    }

}
